<%@page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="s2jsp.bysj.biz.*"%>
<%@page import="s2jsp.bysj.entity.Product"%>
<%!//商品ID
	int productId = 0;%>

<%
	if (request.getParameter("productId") != null) {
		productId = Integer.parseInt(request.getParameter("productId"));
	}

	ProductBiz productBiz = new ProductBiz();

	Product product = null;
	//修改商品信息
	if (productId != 0) {
		//查询并初始化商品对象
		product = productBiz.findProductByProductId(productId);
	} else {
		product = null;
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link href="../css/admin.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="../js/addModifyProduct.js"></script>
		<script type="text/javascript" src="../js/jquery.form.js"></script>


		<title><%=productId == 0 ? "添加商品信息" : "修改商品信息"%></title>
		<script type="text/javascript">
			$(document).ready(function(){$("#submitButton").click(function(){
 		alert("in");})
 });
		</script>
		<style type="text/css">
p {
	margin-left: 15px;
	margin-top: 2px;
}

.inputInfo {
	width: 120px;
}

.productInfoTitle {
	padding-left: 5px;
	width: 5em;
}

.errorInfo {
	text-align: left;
	width: 200px;
}

.inputTd {
	width: 120px;
}

.buttons {
	width: 5em;
}

inputP {
	height: 12px;
	width: 350px;
}
</style>
	</head>

	<body>


		<form id="productForm" name="productForm"
			action="../servlet/addModifyProduct" method="post"
			style="border: 1px solid #6699FF; background: #F5F5DC">
			<p style="background-color: #6699FF; color: #FFFFFF; margin-left: 0">
				<%-- 添加/修改商品信息 --%>
				<b id="webTitle"><%=productId == 0 ? "添加商品信息" : "修改商品信息"%></b>
			</p>


			<p class="inputP" style="margin-top: 5px">
				<span>商品编号:</span>
				<input class="inputInfo" type="text" id="productSerialNumber"
					name="productSerialNumber"
					value="<%=product == null ? "" : product.getSerialNumber()%>"
					onblur="remoteValidateProductProductSerialNumber()"
					<%=product == null ? "" : "readonly=\"readyonly\""%> size="40" />

			</p>
			<p class="errorInfo" id="serialNumError">
				&nbsp;
			</p>
			<%-- 商品名称 --%>
			<p class="inputP">
				<span>商品名称:</span>
				<input class="inputInfo" type="text" id="productName"
					name="productName"
					value="<%=product == null ? "" : product.getName()%>"
					onblur="validateProductName()" size="40" />

			</p>
			<p class="errorInfo" id="productNameError">
				&nbsp;
			</p>

			<%-- 商品商标 --%>
			<p class="inputP">
				<span>商品商标:</span>
				<input class="inputInfo" type="text" id="productBrand"
					name="productBrand"
					value="<%=product == null ? "" : product.getBrand()%>"
					onblur="validateProductBrand()" size="40" />

			</p>
			<p class="errorInfo" id="productBrandError">
				&nbsp;
			</p>

			<p class="inputP">
				<span>商品型号:</span>
				<input class="inputInfo" type="text" id="productType"
					name="productType"
					value="<%=product == null ? "" : product.getType()%>"
					onblur="validateProductType()" size="40" />

			</p>
			<p class="errorInfo" id="productTypeError">
				&nbsp;
			</p>

			<p class="inputP">
				<span>商品价格:</span>
				<input class="inputInfo" type="text" id="productPrice"
					name="productPrice"
					value="<%=product == null ? "" : product.getPrice()%>"
					onblur="validateproductPrice()" size="40" />

			</p>
			<p class="errorInfo" id="priceError">
				&nbsp;
			</p>

			<p class="inputP">
				<span>商品图片:</span>
				<input type="text" class="inputInfo" id="productPicture"
					name="productPicture" value="<%=product == null ? "" : product.getPicture()%>" onblur="validateProductPicture()" size="40" />
					
			</p>
			<p class="errorInfo" id="pictureError">
				&nbsp;
			</p>

			<p>
				<span>商品介绍:</span>
				<textarea id="productDescription" name="productDescription"
					cols="35" rows="6" style="border-left: groove"
					onblur="vadlidateProductDescription()"><%=product == null ? "" : product.getDescription()%></textarea>

			</p>
			<p class="errorInfo" id="descriptionError">
				&nbsp;
			</p>
			<%-- 正在验证图标 --%>
			<p id="validating" style="text-align: center;"></p>
			<%-- 提交后验证信息 --%>
			<p style="text-align: center; display: none">
				&nbsp;
			</p>

			<p style="text-align: center; margin-bottom: 8px">
				<%-- 利用隐藏域传商品ID --%>
				<input type="hidden" id="productId"
					value="<%=productId == 0 ? 0 : productId%>" />
				<input class="buttons" type="button" id="submitButton"
					name="submitButton" value="提交" onclick="addModify()" />
				<input class="buttons" type="reset" id="resetButton"
					name="resetButton" value="重置" onclick="reset()" />

			</p>
		</form>
	</body>

</html>
